package com;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.model.AddressRes;
import com.model.TokenResponse;

import java.io.File;
import java.io.IOException;

public class Run {
    public static void main(String[] args) throws IOException {
        PicBedClient picBedClient = new PicBedClient("https://picui.cn/api/v1","847|M1vyf2l84FjLFRxiwkFZDGAkt4e63irAWt5DvMvz");
        String json = picBedClient.generateUploadToken(2,200000);
        ObjectMapper mapper = new ObjectMapper();
        TokenResponse response = mapper.readValue(json, TokenResponse.class);
        String token = response.getData().getTokens().get(0).getToken();
        String addressJson = picBedClient.uploadImage(new File("C:\\Users\\wy\\Desktop\\广州\\大佛古寺1.jpg"), token);
        System.out.println(addressJson);
        AddressRes addressRes = mapper.readValue(addressJson, AddressRes.class);
        System.out.println(addressRes.getData().getLinks().getUrl().toString());
    }
}
